<?php 

class pictureController extends appController
{
	
	public function clear()
	{
		unset($_SESSION['xywxid']);
		unset($_SESSION['wxid']);
		unset($_SESSION);
	}
	

	
	
	
	public function card()
	{
// 	    $_SESSION['xywxid'] = 24761;
	    
	    $this->check_member();
	
	    $order_id = $_GET['id'];
	    
	    $this->assign_global();
	    
	    $jsdk = Model('suipai')->get_jsdk();
	    
	    $cardList = Model('suipai')->getCardList($order_id);
	    
	    
	    if(!$cardList||!$order_id)
	    {
	        die("非法操作");
	        
	    }
	    
	    $jsdk_card = Model('suipai')->get_jsdk_card($jsdk,$cardList);
	    
	    $this->assign("jsdk", $jsdk);
	    
	    $this->assign("jsdk_card", $jsdk_card);
	    
// 	    var_dump($cardList);
// 	    echo json_encode($cardList);
// 	    exit;
	    $info = Model('suipai')->getRecord($_SESSION['xywxid']);
	    
	    $this->assign('info',$info);
	    
	    $list = Model('suipai')->getList($_SESSION['xywxid']);
	    
	    $this->assign('list',$list);
	    
	    $this->assign("cardList", $cardList);
	
	    $this->display("card.html");
	}
	
	
	public function ajaxCard()
	{
	   
	     
	    $order_id = $_REQUEST['id'];
	        
	    $cardList = Model('suipai')->getCardList($order_id);
	     
	     
	    if(!$cardList||!$order_id)
	    {
	        die("非法操作");
	         
	    }
	     
	    $jsdk_card = Model('suipai')->build_jsdk_card($cardList);
	       
// 	   var_dump($jsdk_card);

	    echo json_encode($jsdk_card);
	   
	}
	
	
	public function ajaxCard2()
	{
	
	
	    $cardList[]['cardId'] = "plHTpwmlhQqJ_6itfucIAlIcADaI";
	
	    $jsdk_card = Model('suipai')->build_jsdk_card2($cardList);
	
	    // 	   var_dump($jsdk_card);
	   
	    echo json_encode($jsdk_card);
	
	}
	
	public function record()
	{
	
	   
				
		$this->check_member();
		
// 		if(!Model('suipai')->isPaySucess($_SESSION['xywxid'])){
// 			$url = "http://g4.shfyuan.com/xy/index.php?g=mobile&m=wxpay&a=main";
// 			header('Location:'.$url);
// 		}
   
		$info = Model('suipai')->getRecord($_SESSION['xywxid']);
		
		$this->assign('info',$info);

		$list = Model('suipai')->getList($_SESSION['xywxid']);
		
		$this->assign('list',$list);
		
		$config[c] = array('site_name' => "购买记录");
		
		$this->assign_global($config);
	
		$jsdk = Model('suipai')->get_jsdk();

		$this->assign("jsdk", $jsdk);
		
		if(!Model('wxpay')->is_saved_user($_SESSION['xywxid'])){
			$is_saved = 'true';
		}else{
			$is_saved = 'false';
		}
		$this->assign("is_saved", $is_saved);
	
		$this->display("record.html");
	}
	

	public function record2()
	{
	
	
	
	  
	
	    $this->assign_global($config);
	
	    $jsdk = Model('suipai')->get_jsdk();
	
	    $this->assign("jsdk", $jsdk);
	
	
			$this->display("record2.html");
		}
		
	
	public function getCard()
	{
	    $id = $_GET['id']?$_GET['id']:0;
        
	    if($id == 0)
	    {
	        die("error".$id);
	    }
	    
	    Model('suipai')->saveCard($_REQUEST['cardList'],$id);

	    echo "success".$id;
	    
	}
	
	

}

?>